﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace IEx.ParserBuilder.Otofun
{
    public class OtofunRequestBuilder : DefaultRequestBuilder
    {
        public OtofunRequestBuilder()
            : base("POST", "application/x-www-form-urlencoded")
        {
        }

        public override void BeginBuildRequest(SourceItem item)
        {
            InternalBuildRequest(item, DateTime.Now, DateTime.Now);
        }

        public override void BuildRequest(ref System.Net.HttpWebRequest request)
        {
            
        }

        protected void InternalBuildRequest(SourceItem item, DateTime from, DateTime to)
        {
           
        }
    }

    public class OtofunRequestBuilderUpdate : OtofunRequestBuilder
    {
        private string searchCode;
        private int? languageId;
        private DateTime? dateFrom;
        private DateTime? dateTo;

        /// <summary>
        /// Create a new instance by providing the particular parameters
        /// </summary>
        /// <param name="searchCode">Company code to find pressreleases</param>
        /// <param name="languageId">
        ///     Language Id to find relatively pressreleases. The value can accept NULL value.
        ///     When value is NULL, it means that for every languages
        /// </param>
        /// <param name="dateFrom">The date to start scanning from</param>
        /// <param name="dateTo">The date to start canning to</param>
        public OtofunRequestBuilderUpdate(string searchCode, int? languageId, DateTime? dateFrom, DateTime? dateTo)
            : base()
        {
            this.searchCode = searchCode;
            this.languageId = languageId;
            this.dateFrom = dateFrom ?? new DateTime(1999, 1, 1);
            this.dateTo = dateTo ?? DateTime.Now;
        }

        public override void BeginBuildRequest(SourceItem item)
        {
            this.InternalBuildRequest(item, this.dateFrom.Value, this.dateTo.Value);
        }
    }
}
